/*
 * MacIP.cpp
 *
 *  Created on: 22.05.2011
 *      Author: mifodix
 */

#include "MacIP.hpp"

void MacIP::SetMac(const char *mac, size_t size)
{
//	size_t begin=sizeof(this->mac)-size;
//	for (size_t i=0; i<begin; i++)
//	{
//		this->mac[i]=0;//зануляем свободные байты слева
//	}
//	for (size_t i=begin, j=0; i<sizeof(this->mac); i++, j++)
//	{
//		this->mac[i]=mac[j];
//	}
	size_t i=0;
	for (; i<size; i++)
	{
		this->mac[i]=mac[i];
	}
	for (; i<sizeof(this->mac)+1; i++)
	{
		this->mac[i]=0;
	}
}

uint32_t MacIP::GetIP() const
{
    return ip;
}

void MacIP::SetIP(uint32_t ip)
{
    this->ip = ip;
}

MacIP::MacIP(const MacIP & copy)
{
	memmove(&this->mac, &copy.mac, sizeof(mac));
	this->ip=copy.ip;
}

MacIP & MacIP::operator =(const MacIP & ob)
{
	if (this!=&ob)
	{
		this->ip=ob.ip;
		memmove(&this->mac, &ob.mac, sizeof(mac));
	}
	return *this;
}

char *MacIP::GetMac() const
{
	char *res=new char[sizeof(mac)];
	memmove(res, &this->mac, sizeof(mac));
	return res;
}

MacIP::MacIP(const char *mac, size_t macSize, uint32_t ip)
{
	SetMac(mac, macSize);
	SetIP(ip);
}

MacIP::~MacIP()
{
}

MacIP::MacIP()
{
}







